const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}

function calPageHeight() {
  // const res = wx.getSystemInfoSync()
  const res = wx.getWindowInfo();
  console.log('res');
  console.log(res);
  const { screenHeight, safeArea: { bottom } } = res;
  console.log(screenHeight,res);
  console.log(screenHeight,bottom);
  let safeBottom = screenHeight;
  if (screenHeight && bottom){
    safeBottom = screenHeight - bottom;
  }
  return 48 + safeBottom;
}

module.exports = {
  formatTime,
  calPageHeight
}
